import React, { Component } from 'react'
import { connect } from "react-redux";
import { ScrollView, Text } from '@tarojs/components'
import ActivityItem from '@components/Activity/index'

import './index.scss'

class Activity extends Component {
  componentWillReceiveProps (nextProps) {
    console.log(this.props, nextProps)
  }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }

  render () {
    const { present = [], history = [] } =  this.props.activity || {}
    return (
      <ScrollView className='pageContent' enableFlex scrollY>
        <Text className="label">进行中的活动</Text>
        {
          present.length > 0 ?
          present.map((item,index) => <ActivityItem key={`activity${index}`} value={item} type='present'/>)
          :
          <Text className="emptyInfo">当前未参加过活动</Text>
        }
        <Text className="label">已完成的活动</Text>
        {
          history.length > 0 ?
          history.map((item,index) => <ActivityItem key={`activity${index}`} value={item} type='history'/>) 
          :
          <Text className="emptyInfo">当前未参加过活动</Text>
        }
      </ScrollView>
    )
  }
}

export default connect(({activity}) => ({activity}),{})(Activity)

